application="bcard-enterprise"
packageName="${application}.jar"
packagePath="web/target/${packageName}"
serverip="192.168.10.13"
serverport="6601"
serverTempDir="/usr/local/vcloud/deploy/"

mvn install
#cd share
#mvn clean install
cd dal
mvn clean install
cd ../biz
mvn clean install
cd ../web
mvn clean package
cd ..

if [ ! -f ${packagePath} ];then
    echo "jar包不存在，请先package"
    exit
fi


echo '开始上传视然名片企业中心服务'
ssh root@${serverip} "rm -rf ${serverTempDir}/${packageName}"
scp ${packagePath} root@${serverip}:${serverTempDir}

ssh root@${serverip} "${serverTempDir}/deploy.sh ${serverport} ${application}"

echo '10秒后开启验证发布是否成功'
sleep 10

for ((k=1;k<=10;k++)) ; do
    result=$(curl -s http://${serverip}:${serverport}/)
    echo ${result}
    contian=$(echo $result | grep "欢迎来到视频名片企业后台")
    if [[ "$contian" != "" ]]
    then
        echo "发布成功"
        break
    else
        echo "发布中，服务还未启动，请稍等..."
        sleep 5
    fi
done

exit
